/**
 * 
 */
package bPlusTree;

import java.io.IOException;
import java.util.Random;

import register.Register;
import register.RegisterID;

import bplustree.BPlusTree;
import junit.framework.TestCase;

/**
 * @author ernesto
 *
 */
public class SearchTest extends TestCase {

	/**
	 * @param arg0
	 */
	public SearchTest(String arg0) {
		super(arg0);
	}

	/**
	 * Test method for {@link bplustree.BPlusTree#search(register.RegisterID)}.
	 * @throws IOException 
	 */
	public void testSearch() throws IOException {

		BPlusTree arbol = new BPlusTree();
		Random randGenerator = new Random();

		int nextid;
		for(int i=0; i<1000; i++ ){
			nextid=randGenerator.nextInt(500);
			if(i%100==0) System.out.println("Insertando registro " + i + " de 1000");
			arbol.insert(new Register(new RegisterID(Integer.toString(nextid)),randGenerator.nextInt(20000)));
		}
			System.out.println("Finalizada insercion, comenzando busqueda");
		nextid=randGenerator.nextInt(500);
			System.out.println("BUSCANDO REGISTRO CON ID = " + nextid);
		Register tempReg=arbol.search(new RegisterID(Integer.toString(nextid)));
			System.out.println("Registro más proximo encontrado:");
			System.out.println("Size; ID||At1|At2|At...");
			System.out.println(tempReg.toStringList());
			
			arbol.finalize();
	}

}
